Option Explicit On Option Strict On Public Class Form1 Inherits System.Windows.Forms.Form Dim songsRated(100) As String Dim ratings(100) As Integer Dim songNum As Integer ' AUTOMATICALLY GENERATED CODE REMOVED ' CODE FOR ASSIGNMENT 8 REMOVED Private Sub BtnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRead.Click Dim input As IO.StreamReader If IO.File.Exists("results.txt") Then input = IO.File.OpenText("results.txt") Do While input.Peek <> -1 And songNum <= 100 Dim curr As String curr = input.ReadLine() Dim commapos As Integer commapos = curr.IndexOf(",") songsRated(songNum) = curr.Substring(0, commapos) ratings(songNum) = Convert.ToInt32(curr.Substring(commapos + 1)) songNum = songNum + 1 Loop End If input.Close() ' artifically show all elements of the array Dim cnt As Integer Dim results As String = "" For cnt = 0 To songNum - 1 results = results & songsRated(cnt) & " Rated: " & ratings(cnt) & Environment.NewLine 'MsgBox(songsRated(cnt) & " Rated: " & ratings(cnt)) Next cnt MsgBox(results) End Sub Private Sub btnShowHigh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowHigh.Click Dim cnt As Integer For cnt = 0 To songNum - 1 If ratings(cnt) >= 4 Then MsgBox(songsRated(cnt) & " Rated: " & ratings(cnt)) End If Next cnt End Sub Private Sub btnAve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAve.Click Dim total As Integer Dim cnt As Integer For cnt = 0 To songNum - 1 total = total + ratings(cnt) Next cnt Dim ave As Double ave = total / cnt MsgBox("ave rating is: " & ave.ToString("n2")) End Sub Private Sub BtnFindRating_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFindRating.Click Dim found As Integer = -1 Dim cnt As Integer For cnt = 0 To songNum - 1 If songsRated(cnt) = TxtSong.Text Then found = cnt End If Next cnt If found = -1 Then MsgBox("Song : " & TxtSong.Text & " not found") Else TxtRating.Text = ratings(found).ToString() End If End Sub Private Sub ButHigh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButHigh.Click Dim cnt As Integer Dim highest As Integer = -1 Dim found As Integer = -1 For cnt = 0 To songNum - 1 If ratings(cnt) > highest Then ' we have a new highest highest = ratings(cnt) found = cnt End If Next cnt MsgBox("Highest Rated song is: " & songsRated(found) & " with a rating of " & highest) End Sub End Class